package com.easybuilder.core.function.service.impl;

import com.easybuilder.core.function.dao.SysFormDao;
import com.easybuilder.core.function.entity.SysForm;
import com.easybuilder.core.function.service.SysFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysFormServiceImpl implements SysFormService {
    @Autowired
    private SysFormDao formDao;

    /** 插入单条 */
    @Override
    public int insertSelective(SysForm sysForm) {
        return formDao.insertSelective(sysForm);
    }

    /** 查询单个 */
    @Override
    public SysForm selectOne(SysForm sysForm) {

        return formDao.selectOne(sysForm);
    }

    /** 根据tableId，级联删除form、formItem*/
    @Override
    public void casecadeDeleteByTableId(Long id) {
        // 先删除formItem
        int del = formDao.casecadeDeleteByTableId(id);
        // 删除form
        SysForm sysForm = new SysForm();
        sysForm.setTableId(id);
        formDao.delete(sysForm);
    }
}
